home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / libray / libobj / allocmatrix.c next >
Encoding:
C/C++ Source or Header  |  1994-08-09  |  613 b   |  37 lines

  1. /*
  2.  * Matrix allocation and freeing Functions.
  3.  *
  4.  * allocmatrix.c
  5.  *
  6.  * Peter Janssen 
  7.  *
  8.  */
  9. #include <stdlib.h>
  10. #include "geom.h"
  11. #include "allocmatrix.h"
  12.  
  13.  
  14. void **allocMatrix(size,  sizeY,  sizeX)
  15. size_t size, sizeY, sizeX;
  16. {
  17. void   **Matrix, **M;
  18. size_t   y;
  19.  
  20.     Matrix = (void *) share_malloc(sizeY * (sizeof(void *)));
  21.     size *= sizeX;
  22.     for (y = sizeY, M = Matrix; y > 0; y--, M++) {
  23.         *M = share_malloc(size);
  24.     }
  25.     return Matrix;
  26. }
  27.  
  28. void freeMatrix(Matrix, sizeY)
  29. void    **Matrix;
  30. size_t    sizeY;
  31. {
  32.     void **M;
  33.  
  34.     for (M=Matrix; sizeY>0; sizeY--, M++) free(*M);
  35.     free(Matrix);
  36. }
  37.